load("@io_bazel_rules_go//go:def.bzl", "go_test")
load("//:RELEASE.bzl", "VERSION")

K8S_CLUSTER_VERSION = "v1.22.0"

go_test(
    name = "test_test",
    timeout = "eternal",
    srcs = [
        "etcd-controller_test.go",
        "main_test.go",
        "proxy-controller_test.go",
    ],
    args = [
        "-test.v=true",
        "-crd=$(location //operator/config/crd:crd)",
        "-cluster-version=" + K8S_CLUSTER_VERSION,
        "-kind-file=$(location @kind//:file)",
        "-proxy-image-file=$(location //container:image.tar)",
        "-rpc-image-file=$(location //container:image_rpcserver.tar)",
        "-dashboard-image-file=$(location //container:image_dashboard.tar)",
        "-operator-image-file=$(location //container:image_operator.tar)",
        "-sidecar-image-file=$(location //container:image_sidecar.tar)",
        "-all-in-one-manifest=$(location //operator/deploy/e2e:all-in-one)",
        "-build-version=" + VERSION,
    ],
    data = [
        "//container:image.tar",
        "//container:image_dashboard.tar",
        "//container:image_operator.tar",
        "//container:image_rpcserver.tar",
        "//container:image_sidecar.tar",
        "//operator/config/crd",
        "//operator/deploy/e2e:all-in-one",
        "@kind//:file",
    ],
    rundir = ".",
    tags = ["e2e"],
    deps = [
        "//operator/e2e/e2eutil",
        "//operator/e2e/framework",
        "//pkg/config/configv2",
        "//pkg/k8s",
        "//pkg/k8s/api/etcd",
        "//pkg/k8s/api/etcd/v1alpha2",
        "//pkg/k8s/controllers",
        "//pkg/k8s/k8sfactory",
        "//pkg/k8s/kind",
        "//pkg/logger",
        "//pkg/testing/btesting",
        "//vendor/go.etcd.io/etcd/client/v3:client",
        "//vendor/golang.org/x/xerrors",
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:meta",
        "//vendor/k8s.io/client-go/rest",
    ],
)
